{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 爬取**联合国教科文组织**微信公众号\n",
    "\n",
    "公众号 = \"联合国教科文组织\"\n",
    "fn = { \"output\" : { \"公众号_htm_snippets\": \"data_raw_src/公众号_htm_snippets_{公众号}.tsv\",\n",
    "                    \"公众号_df\": \"data_raw_src/公众号_df_{公众号}.tsv\",\n",
    "                    \"公众号_xlsx\": \"data_sets/公众号_url_{公众号}.xlsx\" } \\\n",
    "      }"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 用**（selenium）**的方式进行自动化爬取\n",
    "- 打开微信公众号登录界面"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from lxml.html import fromstring\n",
    "import time\n",
    "from random import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Karoja\\AppData\\Roaming\\Python\\Python37\\site-packages\\ipykernel_launcher.py:18: DeprecationWarning: use options instead of chrome_options\n"
     ]
    }
   ],
   "source": [
    "from selenium import webdriver\n",
    "from selenium.webdriver.common.desired_capabilities import DesiredCapabilities\n",
    "\n",
    "#caps=dict()\n",
    "#caps[\"pageLoadStrategy\"] = \"none\"   # Do not wait for full page load\n",
    "\n",
    "opts = webdriver.ChromeOptions()\n",
    "opts.add_argument('--no-sandbox')#解决DevToolsActivePort文件不存在的报错\n",
    "opts.add_argument('window-size=1920x3000') #指定浏览器分辨率\n",
    "opts.add_argument('--disable-gpu') #谷歌文档提到需要加上一这个属性来规避bug\n",
    "opts.add_argument('--hide-scrollbars') #隐藏滚动条, 应对些特殊页面\n",
    "#opts.add_argument('blink-settings=imagesEnabled=false') #不加载图片, 提升速度\n",
    "#opts.add_argument('--headless') #浏览器不提供可视化页面. linux下如果系统不支持可视化不加这条会启动失败\n",
    "\n",
    "opts.binary_location = r\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" #\"H:\\_coding_\\Gitee\\InternetNewMedia\\CapstonePrj2016\\chromedriver.exe\"  \n",
    "\n",
    "# \"H:\\_coding_\\Gitee\\InternetNewMedia\\CapstonePrj2016\\chromedriver.exe\"  \n",
    "driver = webdriver.Chrome( chrome_options = opts) #desired_capabilities=caps,\n",
    "# chromedriver的版本号不一定要一样（最后两位可以不一样）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "driver.get(\"https://mp.weixin.qq.com\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 登录"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 点击账号密码登录\n",
    "payload =  {\"account\": \"863724469@qq.com\", \"password\": \"wanangn4.12\"}\n",
    "driver.find_element_by_xpath('//div[@class=\"login__type__container login__type__container__scan\"]/a').click()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "driver.find_element_by_xpath('//form[@class=\"login_form\"]//input[@name=\"account\"]').clear()\n",
    "driver.find_element_by_xpath('//form[@class=\"login_form\"]//input[@name=\"account\"]').send_keys(payload['account'])\n",
    "driver.find_element_by_xpath('//form[@class=\"login_form\"]//input[@name=\"password\"]').clear()\n",
    "driver.find_element_by_xpath('//form[@class=\"login_form\"]//input[@name=\"password\"]').send_keys(payload['password'])\n",
    "driver.find_element_by_xpath('//div[@class=\"login_btn_panel\"]/a').click()\n",
    "\n",
    "\n",
    "driver.find_element_by_xpath('//div[@class=\"login_btn_panel\"]/a').click()\n",
    "\n",
    "# 登录后的二维码验证需要手动验证！"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 微信公众号后台进行了改版，可直接在登录进来后的首页点击**“图文消息”**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'<i class=\"new-creation__icon new-creation__icon_stroke\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" height=\"32\" viewBox=\"0 0 32 32\"><g fill=\"none\" fill-rule=\"evenodd\"><path stroke-width=\"1.571\" d=\"M6 22.416V27h4.584l13.504-13.505-4.583-4.583L6 22.416zM27.633 9.95a1.182 1.182 0 0 0 0-1.71l-2.872-2.873a1.182 1.182 0 0 0-1.711 0l-2.262 2.262 4.584 4.583 2.261-2.262h0z\"></path></g></svg></i> <div class=\"new-creation__menu-title\">图文消息</div>'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 点击“图文消息”\n",
    "element = driver.find_element_by_xpath('//*[@id=\"app\"]/div[2]/div[3]/div[2]/div/div[1]/div')\n",
    "element.click()\n",
    "main_content = element.get_attribute('innerHTML')\n",
    "main_content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['CDwindow-79A9E01DF3D6024775FAD3C0FD2D32F6', 'CDwindow-E5FED2602383C250B09B4805BCF1CE37']\n"
     ]
    }
   ],
   "source": [
    "# 查看已打开窗口，防止在错误窗口运行剩下的操作\n",
    "print (driver.window_handles)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 选择要运行的窗口\n",
    "driver.switch_to.window(driver.window_handles[1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 选择公众号"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                超链接              \n"
     ]
    }
   ],
   "source": [
    "# 点击“超链接”\n",
    "element = driver.find_element_by_xpath('//*[text()[contains(.,\"超链接\")]]') \n",
    "main_content = element.get_attribute('innerHTML')\n",
    "print(main_content)\n",
    "element.click()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "选择其他公众号\n"
     ]
    }
   ],
   "source": [
    "# 选择其他公众号\n",
    "element = driver.find_element_by_xpath('//*[text()[contains(.,\"选择其他公众号\")]]') \n",
    "main_content = element.get_attribute('innerHTML')\n",
    "print(main_content)\n",
    "element.click()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 输入要爬取的公众号名称\n",
    "driver.find_element_by_xpath('//form//div[@class=\"inner_link_account_area\"]//input[@class=\"weui-desktop-form__input\"]').clear()\n",
    "driver.find_element_by_xpath('//form//div[@class=\"inner_link_account_area\"]//input[@class=\"weui-desktop-form__input\"]').send_keys(公众号)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<div class=\"weui-desktop-icon weui-desktop-icon__inputSearch weui-desktop-icon__small\"><!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <!----> <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M11.33 10.007l4.273 4.273a.502.502 0 0 1 .005.709l-.585.584a.499.499 0 0 1-.709-.004L10.046 11.3a6.278 6.278 0 1 1 1.284-1.294zm.012-3.729a5.063 5.063 0 1 0-10.127 0 5.063 5.063 0 0 0 10.127 0z\"></path></svg> <!----> <!----> <!----> <!----></div>\n"
     ]
    }
   ],
   "source": [
    "# 点放大镜搜，进行搜索\n",
    "element = driver.find_element_by_xpath('//button[@class=\"weui-desktop-icon-btn weui-desktop-search__btn\"]')\n",
    "main_content = element.get_attribute('innerHTML')\n",
    "print(main_content)\n",
    "element.click()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<li class=\"inner_link_account_item\"><div class=\"weui-desktop-vm_primary\"><img src=\"http://mmbiz.qpic.cn/mmbiz_png/NLtXtdp9ewBYl7esg9FORZicqDtia4L8cPnxIg0icadDnsjIyVXmSL8jnoicnibp84HSAXzKriacMFqQHK2DMhbrbsiaQ/0?wx_fmt=png\" class=\"inner_link_account_avatar\"> <strong class=\"inner_link_account_nickname\">联合国教科文组织</strong> <i class=\"inner_link_account_wechat\">微信号：UNESCO_China</i></div> <div class=\"weui-desktop-vm_default inner_link_account_type\">订阅号</div></li><li class=\"inner_link_account_item\"><div class=\"weui-desktop-vm_primary\"><img src=\"http://mmbiz.qpic.cn/mmbiz_png/xjEeIFsiaaIlLeUj7KMkUYrY35vQyGvVGW5zrlaAoQWwAVHQsgMG0Nic3dFXak3qw6DNTvWicFKDOSkYXib0trcTpw/0?wx_fmt=png\" class=\"inner_link_account_avatar\"> <strong class=\"inner_link_account_nickname\">北京市联合国教科文组织协会</strong> <i class=\"inner_link_account_wechat\">微信号：未设置</i></div> <div class=\"weui-desktop-vm_default inner_link_account_type\">订阅号</div></li><li class=\"inner_link_account_item\"><div class=\"weui-desktop-vm_primary\"><img src=\"http://mmbiz.qpic.cn/mmbiz_png/6ZFeJU0WkfwjPW17FmEA0U8Tzt1Mkzod5J1ws7LPH3drsz7r6D7CNbGXIC09SLC6E2WDux9iar7ic8DcTqZY5gzA/0?wx_fmt=png\" class=\"inner_link_account_avatar\"> <strong class=\"inner_link_account_nickname\">甘肃省联合国教科文组织协会</strong> <i class=\"inner_link_account_wechat\">微信号：gsunesco</i></div> <div class=\"weui-desktop-vm_default inner_link_account_type\">订阅号</div></li><li class=\"inner_link_account_item\"><div class=\"weui-desktop-vm_primary\"><img src=\"http://mmbiz.qpic.cn/mmbiz_png/N6pwLicywtkAsgkfRBcsds6XHGRARrgk4y4zJ7AzJicRYF4H2NDHsz0Dm4ib0NRMDmHQ2Pv0ePGLrWhzgRaLFibtJg/0?wx_fmt=png\" class=\"inner_link_account_avatar\"> <strong class=\"inner_link_account_nickname\">联合国教科文信使</strong> <i class=\"inner_link_account_wechat\">微信号：UNESCOcourier</i></div> <div class=\"weui-desktop-vm_default inner_link_account_type\">订阅号</div></li><li class=\"inner_link_account_item\"><div class=\"weui-desktop-vm_primary\"><img src=\"http://mmbiz.qpic.cn/mmbiz_png/BuRNIyibJ3o6AauQibVnq6FxXHaybaacplMxrJgbTcEAaYQ3ozc1SJvgIKtYXEHN1xFgvmQQB1acla2FTrAnicj6g/0?wx_fmt=png\" class=\"inner_link_account_avatar\"> <strong class=\"inner_link_account_nickname\">教科文学前培训基地</strong> <i class=\"inner_link_account_wechat\">微信号：未设置</i></div> <div class=\"weui-desktop-vm_default inner_link_account_type\">服务号</div></li>\n"
     ]
    }
   ],
   "source": [
    "# 搜索结果\n",
    "element = driver.find_element_by_xpath('//ul[@class=\"inner_link_account_list\"]')\n",
    "main_content = element.get_attribute('innerHTML')\n",
    "print(main_content)\n",
    "公众号SERP = main_content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 解析\n",
    "root = fromstring(公众号SERP) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "主 = root.xpath('//li[@class=\"inner_link_account_item\"]')\n",
    "\n",
    "account_list = []\n",
    "\n",
    "for e in 主:\n",
    "    account_nickname = e.xpath('./div/strong[@class=\"inner_link_account_nickname\"]')[0].text\n",
    "    account_wechat = e.xpath('./div/i[@class=\"inner_link_account_wechat\"]')[0].text\n",
    "    account_img = e.xpath('./div/img/@src')[0]\n",
    "    account = {\"nickname\": account_nickname, \"wechat\": account_wechat, \"img\": account_img,}\n",
    "    account_list.append(account)\n",
    "\n",
    "df_account = pd.DataFrame(account_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>nickname</th>\n",
       "      <th>wechat</th>\n",
       "      <th>img</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>联合国教科文组织</td>\n",
       "      <td>微信号：UNESCO_China</td>\n",
       "      <td>http://mmbiz.qpic.cn/mmbiz_png/NLtXtdp9ewBYl7e...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>北京市联合国教科文组织协会</td>\n",
       "      <td>微信号：未设置</td>\n",
       "      <td>http://mmbiz.qpic.cn/mmbiz_png/xjEeIFsiaaIlLeU...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>甘肃省联合国教科文组织协会</td>\n",
       "      <td>微信号：gsunesco</td>\n",
       "      <td>http://mmbiz.qpic.cn/mmbiz_png/6ZFeJU0WkfwjPW1...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>联合国教科文信使</td>\n",
       "      <td>微信号：UNESCOcourier</td>\n",
       "      <td>http://mmbiz.qpic.cn/mmbiz_png/N6pwLicywtkAsgk...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>教科文学前培训基地</td>\n",
       "      <td>微信号：未设置</td>\n",
       "      <td>http://mmbiz.qpic.cn/mmbiz_png/BuRNIyibJ3o6Aau...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        nickname             wechat  \\\n",
       "0       联合国教科文组织   微信号：UNESCO_China   \n",
       "1  北京市联合国教科文组织协会            微信号：未设置   \n",
       "2  甘肃省联合国教科文组织协会       微信号：gsunesco   \n",
       "3       联合国教科文信使  微信号：UNESCOcourier   \n",
       "4      教科文学前培训基地            微信号：未设置   \n",
       "\n",
       "                                                 img  \n",
       "0  http://mmbiz.qpic.cn/mmbiz_png/NLtXtdp9ewBYl7e...  \n",
       "1  http://mmbiz.qpic.cn/mmbiz_png/xjEeIFsiaaIlLeU...  \n",
       "2  http://mmbiz.qpic.cn/mmbiz_png/6ZFeJU0WkfwjPW1...  \n",
       "3  http://mmbiz.qpic.cn/mmbiz_png/N6pwLicywtkAsgk...  \n",
       "4  http://mmbiz.qpic.cn/mmbiz_png/BuRNIyibJ3o6Aau...  "
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_account"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<div class=\"weui-desktop-vm_primary\"><img src=\"http://mmbiz.qpic.cn/mmbiz_png/NLtXtdp9ewBYl7esg9FORZicqDtia4L8cPnxIg0icadDnsjIyVXmSL8jnoicnibp84HSAXzKriacMFqQHK2DMhbrbsiaQ/0?wx_fmt=png\" class=\"inner_link_account_avatar\"> <strong class=\"inner_link_account_nickname\">联合国教科文组织</strong> <i class=\"inner_link_account_wechat\">微信号：UNESCO_China</i></div> <div class=\"weui-desktop-vm_default inner_link_account_type\">订阅号</div>\n"
     ]
    }
   ],
   "source": [
    "# 在搜索出来的公众号里选择要爬取的公众号\n",
    "element = driver.find_element_by_xpath('//ul[@class=\"inner_link_account_list\"]/li')\n",
    "main_content = element.get_attribute('innerHTML')\n",
    "print(main_content)\n",
    "element.click()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\n跳转_input = driver.find_element_by_xpath(\\'//span[@class=\"weui-desktop-pagination__form\"]/input\\')\\n跳转_a = driver.find_element_by_xpath(\\'//span[@class=\"weui-desktop-pagination__form\"]/a\\')\\n跳转_input.clear()\\n跳转_input.send_keys(2)\\n跳转_a.click()\\n'"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 跳转testing\n",
    "'''\n",
    "跳转_input = driver.find_element_by_xpath('//span[@class=\"weui-desktop-pagination__form\"]/input')\n",
    "跳转_a = driver.find_element_by_xpath('//span[@class=\"weui-desktop-pagination__form\"]/a')\n",
    "跳转_input.clear()\n",
    "跳转_input.send_keys(2)\n",
    "跳转_a.click()\n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 176]\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "# 跳转上限\n",
    "l_e = driver.find_elements_by_xpath('//label[@class=\"weui-desktop-pagination__num\"]')\n",
    "l_e_int  = [int(x.text) for x in l_e] \n",
    "print (l_e_int)\n",
    "print (l_e_int[0]==l_e_int[-1])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176]\n"
     ]
    }
   ],
   "source": [
    "pages = list(range(l_e_int[0],l_e_int[-1]+1 ))\n",
    "#print(pages[0:2])\n",
    "pages = list(range(1,l_e_int[-1]+1))\n",
    "print(pages)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 开始循环爬取"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "html_raw = dict()\n",
    "main_content =\"\"\n",
    "element = None"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "def process_pages (pages):\n",
    "    for p in pages:\n",
    "        print (p,end='\\t')\n",
    "\n",
    "        跳转_input = driver.find_element_by_xpath('//span[@class=\"weui-desktop-pagination__form\"]/input')\n",
    "        跳转_a = driver.find_element_by_xpath('//span[@class=\"weui-desktop-pagination__form\"]/a')\n",
    "        跳转_input.clear()\n",
    "        跳转_input.send_keys(p)\n",
    "        跳转_a.click()\n",
    "        \n",
    "# 设置爬取睡眠时间\n",
    "        time.sleep(45+120*random())\n",
    "\n",
    "        element = driver.find_element_by_xpath('//div[@class=\"inner_link_article_list\"]')\n",
    "        main_content = element.get_attribute('innerHTML')\n",
    "        #print(main_content)\n",
    "        html_raw[p] = main_content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\t24\t25\t26\t27\t28\t29\t30\t31\t32\t33\t34\t35\t36\t37\t38\t39\t40\t41\t42\t43\t44\t45\t46\t47\t48\t49\t50\t51\t52\t53\t54\t55\t56\t57\t58\t59\t60\t61\t62\t63\t64\t65\t66\t67\t68\t69\t70\t71\t72\t73\t74\t75\t76\t77\t78\t79\t80\t81\t82\t83\t84\t85\t86\t87\t88\t89\t90\t91\t92\t93\t94\t95\t96\t97\t98\t99\t100\t101\t102\t103\t104\t105\t106\t107\t108\t109\t110\t111\t112\t113\t114\t115\t116\t117\t118\t119\t120\t121\t122\t123\t124\t125\t126\t127\t128\t129\t130\t131\t132\t133\t134\t135\t136\t137\t138\t139\t140\t141\t142\t143\t144\t145\t146\t147\t148\t149\t150\t151\t152\t153\t154\t155\t156\t157\t158\t159\t160\t161\t162\t163\t164\t165\t166\t167\t168\t169\t170\t171\t172\t173\t174\t175\t176\t"
     ]
    }
   ],
   "source": [
    "# 爬取所有页面，等待时间会比较长\n",
    "process_pages(pages)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>html_snippets</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>172</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>173</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>174</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>175</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>176</th>\n",
       "      <td>&lt;div&gt;&lt;label class=\"inner_link_article_item\"&gt;&lt;s...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>176 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                         html_snippets\n",
       "1    <div><label class=\"inner_link_article_item\"><s...\n",
       "2    <div><label class=\"inner_link_article_item\"><s...\n",
       "3    <div><label class=\"inner_link_article_item\"><s...\n",
       "4    <div><label class=\"inner_link_article_item\"><s...\n",
       "5    <div><label class=\"inner_link_article_item\"><s...\n",
       "..                                                 ...\n",
       "172  <div><label class=\"inner_link_article_item\"><s...\n",
       "173  <div><label class=\"inner_link_article_item\"><s...\n",
       "174  <div><label class=\"inner_link_article_item\"><s...\n",
       "175  <div><label class=\"inner_link_article_item\"><s...\n",
       "176  <div><label class=\"inner_link_article_item\"><s...\n",
       "\n",
       "[176 rows x 1 columns]"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame([html_raw]).T\n",
    "df.columns = [\"html_snippets\"]\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Stored 'html_raw' (dict)\n"
     ]
    }
   ],
   "source": [
    "%store html_raw\n",
    "import pickle \n",
    "filehandler = open(\"html_raw\", 'wb') \n",
    "pickle.dump(html_raw, filehandler)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "176\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>html_snippets</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [html_snippets]\n",
       "Index: []"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_out = df[~df.duplicated()]\n",
    "print (len(df_out))\n",
    "df[df.duplicated()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "try_again = list(df[df.duplicated()].index)\n",
    "print(try_again)\n",
    "try_again = try_again + list (set(pages).difference(set(df.index.values)))\n",
    "try_again"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 暂存档"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "filename = fn [\"output\"] [\"公众号_htm_snippets\"] \n",
    "df_out.to_csv(filename.format(公众号=公众号), sep=\"\\t\", encoding=\"utf-8\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "7,6,7,6,9,7,7,7,6,5,9,10,11,11,9,8,11,9,7,6,8,5,5,6,7,5,5,5,5,5,5,6,6,6,7,10,7,7,6,8,6,5,5,8,5,5,5,5,6,5,6,7,10,9,8,10,10,11,9,7,11,10,10,9,10,11,8,7,6,6,5,9,8,5,7,6,7,6,5,7,8,6,8,7,6,5,6,5,6,5,6,6,5,6,6,5,5,5,5,5,5,6,5,7,6,6,7,8,7,12,9,14,10,9,13,7,11,8,12,7,9,8,9,7,6,6,6,10,8,7,8,8,5,5,8,9,6,7,7,6,12,8,11,10,11,5,6,6,6,6,7,4,7,10,5,5,6,5,5,6,6,5,6,5,5,5,5,5,5,6,5,6,7,6,8,8,"
     ]
    }
   ],
   "source": [
    "def parse_html_snippets(_snippet_):\n",
    "    root = fromstring(_snippet_) \n",
    "    title = [x.text for x in root.xpath('//div[@class=\"inner_link_article_title\"]/span[2]')]  # 由于微信公众号后台进行了改版，此处要修改\n",
    "    create_time = [x.text for x in root.xpath('//div[@class=\"inner_link_article_date\"]')]\n",
    "    link = [x for x in root.xpath('//a/@href')]\n",
    "    _df_ = pd.DataFrame({\"title\":title, \"create_time\": create_time, \"link\":link})\n",
    "    return(_df_)\n",
    "    \n",
    "l_df = []\n",
    "for p in pages:\n",
    "    _df_ = parse_html_snippets(df.loc[p,\"html_snippets\"])\n",
    "    print (len(_df_), end=\",\")\n",
    "    l_df.append(_df_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "      <th>create_time</th>\n",
       "      <th>link</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>联合国教科文组织“ResiliArt 坚韧艺术”全球首场线下对话于北京顺利举办</td>\n",
       "      <td>2020-07-16</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>联合国暴力侵害妇女问题特别报告员发布关于女性记者安全的报告</td>\n",
       "      <td>2020-07-16</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>联合国教科文组织呼吁在5G时代构建包容性知识社会</td>\n",
       "      <td>2020-07-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>今晚8点直播 | 妇女为普天下采取行动</td>\n",
       "      <td>2020-07-14</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2020《世界粮食安全和营养状况》发布！</td>\n",
       "      <td>2020-07-14</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>教科文组织在亚、欧、拉美新立15个世界地质公园</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>联合国教科文组织关于伊斯坦布尔圣索菲亚大教堂的声明</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>新冠肺炎疫情：关于难民教育问题你需要知道这些</td>\n",
       "      <td>2020-07-10</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>各方期待教科文组织采取措施 打击气候变化虚假信息</td>\n",
       "      <td>2020-07-09</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>教科文组织邀请教师加入“和平守护者”线上共学社区</td>\n",
       "      <td>2020-07-08</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>教科文组织城市平台召集利益攸关方共商城市未来</td>\n",
       "      <td>2020-07-07</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                      title create_time  \\\n",
       "0   联合国教科文组织“ResiliArt 坚韧艺术”全球首场线下对话于北京顺利举办  2020-07-16   \n",
       "1             联合国暴力侵害妇女问题特别报告员发布关于女性记者安全的报告  2020-07-16   \n",
       "2                  联合国教科文组织呼吁在5G时代构建包容性知识社会  2020-07-15   \n",
       "3                       今晚8点直播 | 妇女为普天下采取行动  2020-07-14   \n",
       "4                      2020《世界粮食安全和营养状况》发布！  2020-07-14   \n",
       "5                   教科文组织在亚、欧、拉美新立15个世界地质公园  2020-07-13   \n",
       "6                 联合国教科文组织关于伊斯坦布尔圣索菲亚大教堂的声明  2020-07-13   \n",
       "7                    新冠肺炎疫情：关于难民教育问题你需要知道这些  2020-07-10   \n",
       "8                  各方期待教科文组织采取措施 打击气候变化虚假信息  2020-07-09   \n",
       "9                  教科文组织邀请教师加入“和平守护者”线上共学社区  2020-07-08   \n",
       "10                   教科文组织城市平台召集利益攸关方共商城市未来  2020-07-07   \n",
       "\n",
       "                                                 link  \n",
       "0   http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "1   http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "2   http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "3   http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "4   http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "5   http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "6   http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "7   http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "8   http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "9   http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "10  http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  "
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_url_out = pd.concat(l_df).reset_index(drop=True)\n",
    "df_url_out.loc[0:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "      <th>create_time</th>\n",
       "      <th>link</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>value</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2020《世界粮食安全和营养状况》发布！</td>\n",
       "      <td>2020-07-14</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>教科文组织在亚、欧、拉美新立15个世界地质公园</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>各方期待教科文组织采取措施 打击气候变化虚假信息</td>\n",
       "      <td>2020-07-09</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>教科文组织邀请教师加入“和平守护者”线上共学社区</td>\n",
       "      <td>2020-07-08</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>教科文组织城市平台召集利益攸关方共商城市未来</td>\n",
       "      <td>2020-07-07</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1233</th>\n",
       "      <td>\"世界遗产地可持续旅游”论坛将在三清山召开</td>\n",
       "      <td>2015-05-18</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1234</th>\n",
       "      <td>“太平洋西岸最美的花岗岩”——三清山</td>\n",
       "      <td>2015-05-18</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1236</th>\n",
       "      <td>卢森堡男首相都公开“嫁“了，你还恐同么？</td>\n",
       "      <td>2015-05-17</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1237</th>\n",
       "      <td>彩虹旗只有六色？你没数错！</td>\n",
       "      <td>2015-05-17</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1240</th>\n",
       "      <td>爵士乐意味着什么？</td>\n",
       "      <td>2015-04-30</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>666 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                          title create_time  \\\n",
       "value                                         \n",
       "4          2020《世界粮食安全和营养状况》发布！  2020-07-14   \n",
       "5       教科文组织在亚、欧、拉美新立15个世界地质公园  2020-07-13   \n",
       "8      各方期待教科文组织采取措施 打击气候变化虚假信息  2020-07-09   \n",
       "9      教科文组织邀请教师加入“和平守护者”线上共学社区  2020-07-08   \n",
       "10       教科文组织城市平台召集利益攸关方共商城市未来  2020-07-07   \n",
       "...                         ...         ...   \n",
       "1233      \"世界遗产地可持续旅游”论坛将在三清山召开  2015-05-18   \n",
       "1234         “太平洋西岸最美的花岗岩”——三清山  2015-05-18   \n",
       "1236       卢森堡男首相都公开“嫁“了，你还恐同么？  2015-05-17   \n",
       "1237              彩虹旗只有六色？你没数错！  2015-05-17   \n",
       "1240                  爵士乐意味着什么？  2015-04-30   \n",
       "\n",
       "                                                    link  \n",
       "value                                                     \n",
       "4      http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "5      http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "8      http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "9      http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "10     http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "...                                                  ...  \n",
       "1233   http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "1234   http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "1236   http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "1237   http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "1240   http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "\n",
       "[666 rows x 3 columns]"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# tagging 标记\n",
    "# 设置自己想要的关键词\n",
    "tagging_list = [\"\",\"男孩\",\"女孩\",\\\n",
    "                \"儿童\",\"教师,\"\\\n",
    "                \"生活\",\\\n",
    "                \"教育\",\\\n",
    "                \"可持续发展\", \"经济\",\\\n",
    "                \"战争\",\"非洲\",\"妇女\",\\\n",
    "                \"女性\",\"快乐\",\"联合国\",\\\n",
    "                \"家庭\",\"学习\", \"孩子\", \\\n",
    "                \"疫情\",\"停课\",\\\n",
    "                \"性别\",] #overwritable\n",
    "\n",
    "v_v_list = []\n",
    "\n",
    "for tag in tagging_list:\n",
    "    index_list = df_url_out [ df_url_out.title.str.contains(tag) ].index.tolist()\n",
    "    v_v_pairs = pd.DataFrame({tag:index_list}).melt().set_index(\"value\")\n",
    "    v_v_list.append(v_v_pairs)\n",
    "\n",
    "df_cat = v_v_list[0]\n",
    "for d in v_v_list:\n",
    "    df_cat.update(d)\n",
    "    \n",
    "# 尚未标记内容\n",
    "df_url_out.loc [ df_cat.query('variable==\"\"').index ]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA==&mid=2652376645&idx=1&sn=dffe458d4c58f0a0c309392640ec7bc2&chksm=84d0bf88b3a7369e9b36bf3554d28bda1f69eb66e9dc06fa2a6a5653ebaff94cbdbf26199e65#rd'"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_url_out.loc[24].link"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "      <th>create_time</th>\n",
       "      <th>link</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [title, create_time, link]\n",
       "Index: []"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_url_out[df_url_out.duplicated()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "      <th>create_time</th>\n",
       "      <th>link</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>嘻哈音乐挽救生命：教科文组织、创新政策基金会和难民署合力 #拒绝病毒，对抗新冠信息疫情</td>\n",
       "      <td>2020-05-13</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>我……#和她站在一起#</td>\n",
       "      <td>2020-05-13</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>联合国发行“弗洛伦斯·南丁格尔诞辰200周年”邮票</td>\n",
       "      <td>2020-05-12</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>《信使》| 考古与世界文化遗产：2019年中国十大考古新发现</td>\n",
       "      <td>2020-05-12</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>联合国驻华机构与教育部召开网络会议，就教育系统应对新冠疫情加强合作</td>\n",
       "      <td>2020-05-11</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>853</th>\n",
       "      <td>教科文组织与法国国家科学研究中心联合启动欧洲科学外交项目InsSciDE</td>\n",
       "      <td>2018-01-23</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>854</th>\n",
       "      <td>发展非洲全民素质教育的优先事项</td>\n",
       "      <td>2018-01-23</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>855</th>\n",
       "      <td>教科文组织征集2018年教科文组织马丹吉特·辛格促进宽容和非暴力奖提名</td>\n",
       "      <td>2018-01-22</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>856</th>\n",
       "      <td>教科文组织动员纪念缅怀大屠杀受难者国际纪念日</td>\n",
       "      <td>2018-01-22</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>857</th>\n",
       "      <td>联合国教科文组织创意城市设立桑托斯-万隆电影节并强调可持续发展</td>\n",
       "      <td>2018-01-22</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>847 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                           title create_time  \\\n",
       "0    嘻哈音乐挽救生命：教科文组织、创新政策基金会和难民署合力 #拒绝病毒，对抗新冠信息疫情  2020-05-13   \n",
       "1                                    我……#和她站在一起#  2020-05-13   \n",
       "2                      联合国发行“弗洛伦斯·南丁格尔诞辰200周年”邮票  2020-05-12   \n",
       "3                 《信使》| 考古与世界文化遗产：2019年中国十大考古新发现  2020-05-12   \n",
       "4              联合国驻华机构与教育部召开网络会议，就教育系统应对新冠疫情加强合作  2020-05-11   \n",
       "..                                           ...         ...   \n",
       "853         教科文组织与法国国家科学研究中心联合启动欧洲科学外交项目InsSciDE  2018-01-23   \n",
       "854                              发展非洲全民素质教育的优先事项  2018-01-23   \n",
       "855          教科文组织征集2018年教科文组织马丹吉特·辛格促进宽容和非暴力奖提名  2018-01-22   \n",
       "856                       教科文组织动员纪念缅怀大屠杀受难者国际纪念日  2018-01-22   \n",
       "857              联合国教科文组织创意城市设立桑托斯-万隆电影节并强调可持续发展  2018-01-22   \n",
       "\n",
       "                                                  link  \n",
       "0    http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "1    http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "2    http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "3    http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "4    http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "..                                                 ...  \n",
       "853  http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "854  http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "855  http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "856  http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "857  http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...  \n",
       "\n",
       "[847 rows x 3 columns]"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_url_out[~df_url_out.duplicated()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "      <th>create_time</th>\n",
       "      <th>link</th>\n",
       "      <th>variable</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>联合国教科文组织“ResiliArt 坚韧艺术”全球首场线下对话于北京顺利举办</td>\n",
       "      <td>2020-07-16</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "      <td>联合国</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>联合国暴力侵害妇女问题特别报告员发布关于女性记者安全的报告</td>\n",
       "      <td>2020-07-16</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "      <td>联合国</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>联合国教科文组织呼吁在5G时代构建包容性知识社会</td>\n",
       "      <td>2020-07-15</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "      <td>联合国</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>今晚8点直播 | 妇女为普天下采取行动</td>\n",
       "      <td>2020-07-14</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "      <td>妇女</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2020《世界粮食安全和营养状况》发布！</td>\n",
       "      <td>2020-07-14</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "      <td>无法分类</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1236</th>\n",
       "      <td>卢森堡男首相都公开“嫁“了，你还恐同么？</td>\n",
       "      <td>2015-05-17</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "      <td>无法分类</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1237</th>\n",
       "      <td>彩虹旗只有六色？你没数错！</td>\n",
       "      <td>2015-05-17</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "      <td>无法分类</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1238</th>\n",
       "      <td>“快乐校园”大调查</td>\n",
       "      <td>2015-05-06</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "      <td>快乐</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1239</th>\n",
       "      <td>让妇女形象上首页！</td>\n",
       "      <td>2015-05-04</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "      <td>妇女</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1240</th>\n",
       "      <td>爵士乐意味着什么？</td>\n",
       "      <td>2015-04-30</td>\n",
       "      <td>http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...</td>\n",
       "      <td>无法分类</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1241 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                        title create_time  \\\n",
       "0     联合国教科文组织“ResiliArt 坚韧艺术”全球首场线下对话于北京顺利举办  2020-07-16   \n",
       "1               联合国暴力侵害妇女问题特别报告员发布关于女性记者安全的报告  2020-07-16   \n",
       "2                    联合国教科文组织呼吁在5G时代构建包容性知识社会  2020-07-15   \n",
       "3                         今晚8点直播 | 妇女为普天下采取行动  2020-07-14   \n",
       "4                        2020《世界粮食安全和营养状况》发布！  2020-07-14   \n",
       "...                                       ...         ...   \n",
       "1236                     卢森堡男首相都公开“嫁“了，你还恐同么？  2015-05-17   \n",
       "1237                            彩虹旗只有六色？你没数错！  2015-05-17   \n",
       "1238                                “快乐校园”大调查  2015-05-06   \n",
       "1239                                让妇女形象上首页！  2015-05-04   \n",
       "1240                                爵士乐意味着什么？  2015-04-30   \n",
       "\n",
       "                                                   link variable  \n",
       "0     http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...      联合国  \n",
       "1     http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...      联合国  \n",
       "2     http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...      联合国  \n",
       "3     http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...       妇女  \n",
       "4     http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...     无法分类  \n",
       "...                                                 ...      ...  \n",
       "1236  http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...     无法分类  \n",
       "1237  http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...     无法分类  \n",
       "1238  http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...       快乐  \n",
       "1239  http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...       妇女  \n",
       "1240  http://mp.weixin.qq.com/s?__biz=MzA3MDQ4NjE3OA...     无法分类  \n",
       "\n",
       "[1241 rows x 4 columns]"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_o = df_url_out.join(df_cat).replace(\"\", np.nan).fillna(\"无法分类\")\n",
    "df_o"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>variable</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>无法分类</th>\n",
       "      <td>666</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>联合国</th>\n",
       "      <td>302</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>教育</th>\n",
       "      <td>94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>疫情</th>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>可持续发展</th>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>学习</th>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>妇女</th>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>性别</th>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>停课</th>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>非洲</th>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>女性</th>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>女孩</th>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>儿童</th>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>经济</th>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>快乐</th>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>家庭</th>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>孩子</th>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>战争</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>男孩</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          title\n",
       "variable       \n",
       "无法分类        666\n",
       "联合国         302\n",
       "教育           94\n",
       "疫情           46\n",
       "可持续发展        28\n",
       "学习           23\n",
       "妇女           16\n",
       "性别           14\n",
       "停课           11\n",
       "非洲           11\n",
       "女性            9\n",
       "女孩            5\n",
       "儿童            4\n",
       "经济            3\n",
       "快乐            3\n",
       "家庭            2\n",
       "孩子            2\n",
       "战争            1\n",
       "男孩            1"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_stats = df_o.groupby(by=\"variable\").agg({\"title\":\"count\"}).sort_values(by=\"title\", ascending=False)\n",
    "df_stats"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 输出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_account.columns.name = \"rel_accounts\"\n",
    "df_o.columns.name = \"url_cat\"\n",
    "df_stats.columns.name = \"stats\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "_df_.columns.name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [],
   "source": [
    "with pd.ExcelWriter(fn[\"output\"][\"公众号_xlsx\"].format(公众号=公众号)) as writer:\n",
    "    workbook  = writer.book\n",
    "\n",
    "    for _df_ in [df_account, df_o, df_stats]:\n",
    "        _df_.to_excel(writer, sheet_name = _df_.columns.name)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
